import java.util.Scanner;

public class Main1631 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int x= sc.nextInt();
        int a=x/1000;
        int b=x%1000;
        if (a>b){
            System.out.println(x);
        }else {
            System.out.println(b*1000+a);
        }
    }
}
